import request from '../utils/request.js'

//文章列表查询
export const articleListService = (params)=>{
    return  request.get('/article/list',{params:params})
}

//文章详情
export const articleDetailService = (articleid) => {

    return request.get('/article/detail?id='+articleid)
  
}

//添加文章
export const articleAddService = (article) => {
    
    return request.post('/article/add',article)
  
}

//更新文章
export const articleUpdateService = (articledata) => {
    const params = new URLSearchParams()

    params.append('id',articledata.value.id)
    params.append('title',articledata.value.title)
    params.append('category',articledata.value.category)
    params.append('abstracts',articledata.value.abstracts)
    params.append('content',articledata.value.content)

    return request.patch('/article/update',params)
  
}

//文章点赞
export const articleLikeService = (articleid) => {

    return request.get('/article/like?id='+articleid)
  
}

//访问他人空间,查看他人的文章列表
export const otherArticleService = (userid) => {

    return request.get('/article/lists?userid='+userid)

}

//用户帖子管理
export const userallArticleService = () => {

    return request.get('/article/all')

}

//用户删除自己已经发布的帖子
export const articleDeleteService = (id) => {

    return request.delete('/article/delete?id='+id)

}